<?php
include ('chek.php');
//删除掉管理员信息
$aid=$input->get('aid');
if($input->get('aid')){
    if($aid==$session_user['aid']){
        die('不能删除自己！');
        exit;
    }
    else{
        $del_sql="delete from admin WHERE aid='{$aid}'";
        $del_result=$db->query($del_sql);
        if($del_result){
            header('location:auser.php');
        }else{
            die('删除失败！');
        }
    }
}
//获取admin数据
$sql="select * from admin ";
$sql_result=$db->query($sql);
$rows=array();
while ($row=$sql_result->fetch_array(MYSQLI_ASSOC)){
    $rows[]=$row;
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <title>管理员管理</title>
    <?php include (PATH.'/headr.php') ?>
</head>
<body>
<?php include ('nac.inc.php'); ?>
<div class="container">
    <div class="row">
        <h2>管理员管理<small class="pull-right"><a class="btn btn-default" href="auser_add.php">添加管理员</a></small></h2>
        <table class="table table-striped">
            <thead>
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>管理</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($rows as $row):?>
            <tr>
                <td><?php echo $row['aid']?></td>
                <td><?php echo $row['auser']?></td>
                <td>
                    <a href="auser_add.php?aid=<?php echo $row['aid']?>">修改</a>
                    <a href="auser.php?aid=<?php echo $row['aid']?>">删除</a>
                </td>
            </tr>
            <?php endforeach;?>
            </tbody>
        </table>
    </div>
</div>
</body>
</html>